package jobhunter.model;

import java.util.GregorianCalendar;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import jobhunter.model.enums.ActionState;
import jobhunter.model.enums.ActionType;
import jobhunter.model.enums.CommunicationType;
import jobhunter.security.SecurityContext;

@Entity
public class Action
{
	@Id
	@GeneratedValue
	private Long id;
	@ManyToOne
	private User user;
	private String name;
	private GregorianCalendar actionDate;
	private int realized;

	@Enumerated(EnumType.STRING)
	private ActionState state;
	private String cv;
	private String motivationLettre;	
	private String description;	
	@Enumerated(EnumType.STRING)
	private CommunicationType communicationType;

	@Enumerated(EnumType.STRING)
	private ActionType actionType;
	@ManyToOne
	private Process process;
	@ManyToOne
	private Contact contact;
	
	
	public Action(){}
	
	public Action(String name, GregorianCalendar actionDate, int realized,
			 String cv, String motivationLettre, String description,ActionState state,
			 CommunicationType communicationType, ActionType actionType)
	{
		super();
		this.name = name;
		this.actionDate = actionDate;
		this.realized = realized;
		this.state = state;
		this.cv = cv;
		this.motivationLettre = motivationLettre;
		this.description = description;
		this.communicationType = communicationType;
		this.actionType = actionType;
		this.user = SecurityContext.getUser();
	}

	public Long getId()
	{
		return id;
	}

	public User getUser()
	{
		return user;
	}

	public String getName()
	{
		return name;
	}

	public GregorianCalendar getActionDate()
	{
		return actionDate;
	}

	public int getRealized()
	{
		return realized;
	}

	public ActionState getState()
	{
		return state;
	}

	public String getCv()
	{
		return cv;
	}

	public String getMotivationLettre()
	{
		return motivationLettre;
	}

	public String getDescription()
	{
		return description;
	}

	public CommunicationType getCommunicationType()
	{
		return communicationType;
	}

	public ActionType getActionType()
	{
		return actionType;
	}

	public Process getProcess()
	{
		return process;
	}

	public Contact getContact()
	{
		return contact;
	}

	public void setUser(User user)
	{
		this.user = user;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public void setActionDate(GregorianCalendar actionDate)
	{
		this.actionDate = actionDate;
	}

	public void setRealized(int realized)
	{
		this.realized = realized;
	}

	public void setState(ActionState state)
	{
		this.state = state;
	}

	public void setCv(String cv)
	{
		this.cv = cv;
	}

	public void setMotivationLettre(String motivationLettre)
	{
		this.motivationLettre = motivationLettre;
	}

	public void setDescription(String description)
	{
		this.description = description;
	}

	public void setCommunicationType(CommunicationType communicationType)
	{
		this.communicationType = communicationType;
	}

	public void setActionType(ActionType actionType)
	{
		this.actionType = actionType;
	}

	public void setProcess(Process process)
	{
		this.process = process;
	}

	public void setContact(Contact contact)
	{
		this.contact = contact;
	}	

	public String getActionDateString()
	{
		return actionDate.get(GregorianCalendar.DATE)+"/"+actionDate.get(GregorianCalendar.MONTH)+"/"+actionDate.get(GregorianCalendar.YEAR);
	}
}